<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="elibrary.*"%>
<%@ include file="config.jsp" %>    

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>My-Library</title>
        <meta name="keywords" content="My Library" />
        <meta name="description" content="Library" />
        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <link href="css/jquery.ennui.contentslider.css" rel="stylesheet" type="text/css" media="screen,projection" />
        <script language="javscript" type="text/javascript" src="js/jquery.min.js"></script>
        <script language="javascript" type="text/javascript" src="js/ajax.js"></script>
    </head>
    <body>
        <div id="templatemo_header_wrapper">

            <div id="templatemo_header">

                <div id="site_logo"><img src="images/logo.jpeg" width="100" height="100"/></div><div align="left"><img src="images/header.png"/></div>
            </div> <!-- end of header -->
        </div><!-- end of header wrapper -->

        <div id="templatemo_menu_wrapper">

            <div id="templatemo_menu">
                <ul>
                    <li><a href="home.jsp">Home</a></li>
                    <li><a href="browseBooks.jsp" class="current">Browse Books</a></li>
                    <li><a href="showReservation.jsp">Reserved Books</a></li>
                    <li><a href="about.jsp">About</a></li>
                    <li><a href="contact.jsp" class="last">Contact Us</a></li>
                </ul>
            </div> <!-- end of menu -->
        </div> <!-- end of menu wrapper -->

        <div id="tempatemo_content_wrapper">

            <%
	
            //this block checks if the user is logged in and if he is then he is given an option to browse books present in the library
	
            try
        {
		
                    //the user id is fetched and the if the user is not valid then he is redirected to the index page
    	
            String uid=(String)session.getAttribute("uid");
            if(uid==null||uid.equals(""))
            {
                    response.sendRedirect("index.jsp");
            }
    	
            //decryption of user id is done
    	
            DesEncrypter encrypter = new DesEncrypter();
                    int uid1 = Integer.parseInt(encrypter.decrypt(uid));
            Connection con=DaoConnection.getcon(connectURL, DBuser, DBpass);
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery("SELECT * from USERS WHERE UID="+uid1);
            rs.next();
            %>
            <div id="templatemo_content">

                <div class="content_top">

                </div>

                <div id="content_panel">

                    <div id="column_w610">

                        <h1>Welcome <%=rs.getString("USERNAME") %>,</h1>
                        <%}catch(Exception e){e.printStackTrace();}
                        %>
                        <form name="browseform">
                            <table>
                                <tr>
                                    <td>Search by</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td><select name="type" onchange="getsearchresult()">
                                            <option value="">--select--</option>
                                            <option value="bookname">book/journal</option>
                                            <option value="author">author</option>
                                            <option value="subject">subject</option>
                                            <option value="category">category</option>
                                            <option value="tags">tags</option>
                                        </select>
                                    </td>
                                    <td><input type="text" name="searchvalue" onkeyup="getsearchresult()"/></td>
                                </tr>
                            </table>
                        </form>
                        <br/><br/>

                        <div class="header_05"> Search Result (Click on Book id to view details) :</div>
                        <table class="browsebooks">
                            <tr>
                                <td style="width:82px;">Book Id</td>
                                <td style="width:110px;">Book Name</td>
                                <td style="width:82px">Author</td>
                                <td style="width:82px;">Subject</td>
                                <td style="width:82px;">Category</td>
                                <td style="width:110px;">Tags</td>
                            </tr>
                        </table>
                        <div id="ajaxloader" align="center"><img src="images/ajax-loader.gif"/></div>
                        <div id="searchresult">
                        </div>






                    </div> <!-- end of column w610 -->

                    <div id="column_w290">

                        <div id="vertical_menu">
                            <ul>
                                <li><a href="changePassword.jsp">Change Password</a></li>
                                <li><a href="requestBook.jsp">Request New Book</a></li>
                            </ul>
                        </div> <!-- end of menu -->

                        <div class="choose_options">
                            <div class="opt_hand"><img src="images/hand.gif" height="35" width="50"/>
                            </div>
                            <div class="opt_content">
                                <div class="header_05"><a href="#">Browse Books/Journals</a></div>
                            </div>

                            <div class="cleaner"></div>
                        </div>

                        <div class="choose_options">
                            <div class="opt_hand"><img src="images/hand.gif" height="35" width="50"/>
                            </div>
                            <div class="opt_content">
                                <div class="header_05"><a href="#">Make Requests for Books/Journals</a></div>
                            </div>

                            <div class="cleaner"></div>
                        </div>

                        <div class="header_02">Subscribe Newsletter</div>

                        <div class="column_w290_content">

                            <form action="#" method="get">
                                <input type="text" value="Please enter your email address" name="q" size="10" class="inputfield" title="email address" onfocus="clearText(this)" onblur="clearText(this)" />

                                <input type="submit" name="submit" value="Submit" alt="Search" class="submitbutton" title="submit" />
                            </form>

                        </div>
                    </div> <!-- end of column 290 -->

                    <div class="cleaner"></div>

                </div> <!-- end of content panel -->

                <div class="cleaner"></div>
            </div> <!-- end of content -->

        </div> <!-- end of content wrapper -->

        <div id="templatemo_footer_wrapper">

            <div id="templatemo_footer">

                <center>Copyright &#169; 2010 MyLibrary &nbsp &nbsp | &nbsp &nbsp <a href="termsandconditions.jsp"><font color="#828c96"> Terms and Conditions</font></a> </center><br></br>
                <center><b>Disclaimer:</b> No Part of this site can be copied or reproduced in any form, excepting for personal information, without the written permission of the owners.</center>
            </div> <!-- end of footer -->
        </div> <!-- end of footer -->
    </body>
</html>

